<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title>
  <script type="text/javascript" src="../vue.js"></script>
</head>

<style>
  .box {
    width: 50px;
    height: 50px;
    background-color: lawngreen;
  }
  .box1 {
    width: 100px;
    height: 100px;
    background-color: red;
  }
  .c {
    width:200px;
    height: 200px;
    background-color: blue;
  }
  .box3 {
    width: 300px;
    height: 300px;
    background-color: green;
  }
  .div {
    height: 100px;
    background-color: aqua;
  }
</style>

<body>
  <!-- @click.stop  阻止传播 -->
  <!-- @contextmenu.prevent  禁止鼠标右键 -->

  <div id="app">

    <a href="https://www.baidu.com/" @click.prevent="">这是被prevent断了腿的A标签</a>
    <hr>
    <div class="div" @click="fn1">
      outer
      <button @click.stop="fn1">inner</button>
      <!-- 合写 阻止默认事件（常用）  阻止事件冒泡（常用 -->
      <a href="http://www.qq.com" @click.prevent.stop="fn1">点我提示</a>
    </div>
    <hr>
    <div @click="fn2">
      outer
      <div @click="fn1">inner 正常冒泡</div>
    </div>

    <hr>
    


    <br>

    <div class="box" @contextmenu.prevent="">禁止右键</div>
    <input @click.once="fn3" value="一次性事件" type="text">
    <input @keyup="fn4" value="键盘抬起" type="text">
    <input @keyup.13="enter" value="回车" type="text">
    <input @keyup.enter="enter" value="回车" type="text">
    <input type="text" value="空格" @keyup.space="fn1">
    <input type="text" value="tab" @keydown.tab="fn2">
    <input type="text" value="退出" @keydown.esc="fn1">

    <br>

    <!-- 只有event.target是当前操作的元素时才触发事件； -->
    <div class="box3" @click.self="al">
      <button @click="al">点我提示信息</button>
    </div>



  </div>
</body>
<script type="text/javascript">
  Vue.config.productionTip = false;
  const vm = new Vue({
    el: "#app",
    data() {
      return {

      }
    },
    methods: {
      al(){
        alert("你好vue")
      },
      fn1() {
        console.log('fn11111111');
      },
      fn2() {
        console.log('fn22222222222');
      },
      fn3() {
        console.log('就一次');
      },
      fn4() {
        console.log('键盘按下了');
      },
      enter() {
        console.log('keyup.enter 修饰符');
      }
    }
  })
</script>

</html>